<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>

<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<script src="<?= base_url() ?>js/chosen.jquery.js" type="text/javascript"></script>
<!-- CSS -->
<!--<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />-->
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/chosen.css" />

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
	$value = array(
		'id_surat'			=> "",
		'deskripsi'			=> "",
		'userfile'			=> "",
		'legend'				=> "Form Upload File",
		'info'					=> "Form Upload File",
		'act_form'				=> "upload_surat/input_surat/".$id_kategori
	);
	
	//Setting Value pada form Jika melakukan prosedur Edit terhadap data tertentu.
	if($status == "edit"){
		foreach($rs_surat->result() as $row){
			$value['id_surat'] = $row->ID_SURAT;
			$value['deskripsi'] = $row->DESKRIPSI;
			$value['userfile'] = $row->URL_UPLOAD_SURAT;
		}
		$value['legend'] = "Form Upload Surat";
		$value['info'] = "Form Upload Surat";
		$value['act_form'] = "upload_surat/edit_surat/".$value['id_surat'].'/'.$id_kategori;
	}//end if
	
	?>
	<?= form_open($value["act_form"],'class="wufoo" name="form_uploadsurat" enctype="multipart/form-data"'); ?>
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	<div>
		<?= anchor(site_url('upload_surat/index/'.$id_kategori),img(array('src'=>'images/main/38.png','border'=>'0','alt'=>'')).' Kembali ke daftar Upload File','Menampilkan halaman Daftar Upload File'); ?>
	</div>
	<?php if (!empty($err_msg)): ?>
		<div class="ret_error">
			<?php echo $err_msg; ?>
		</div>
	<?php endif; ?>
 <!-- Konten -------------------------------------------------------------------------->
 <div id="contentform">
	<ul>
		<li>
			<label class="desc">Deskripsi *</label>
			 <div>
				<input class="field text" type="text" maxlength="300" size="50" name="deskripsi" value="<? if(set_value('deskripsi')!='') echo set_value('deskripsi'); else echo $value['deskripsi'];?>"/> 
			</div>
            <p class="instruct">
                Masukkan Deskripsi Pada Kolom ini.			
            </p>
		</li>
		<?php echo form_error('deskripsi'); ?>
		
		<li>
			<label class="desc">File</label><i>Max 5 MB</i>
			<div>
				<input type="file" name="userfile" size="20" />
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>Format : pdf, doc, docx, xls, xlsx, jpg (max : 5 MB)</b>
			</div>
			<p class="instruct">
				Masukkan File Materi pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('userfile'); ?>
		<?if($status=='edit' and $value['userfile']!=''){?>
			<li>
				<div>
					<a href="<?php echo base_url()?>uploads/file/<?= $nama_kategori?>/<?php echo $value['userfile']?>"><?php echo $value['userfile'];?></a>&nbsp;&nbsp;<a href="../../../deletefile/<?= $value['id_surat']?>/<?= $value['userfile']?>/<?= $id_kategori?>"><img src="<?php echo base_url()?>images/delete2.png"></a>
				</div>
			</li>
		<?}?>
		<input type="hidden" id="fileold" name="fileold" value="<?=$value['userfile']?>">
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Simpan" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>	
<?= form_close(); ?>
</form>
</div><!--container-->